﻿using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Collections.Generic;

namespace BackUpAnyWhere
{
    class Autorun
    {
        static string AutorunFileName = Path.GetPathRoot(Application.ExecutablePath) + "autorun.inf";

        public static bool isAutorunExist()
        {
            return (IniFileHandle.isFileExist(AutorunFileName));
        }

        public static void AutorunCreate()
        {
            IniFileHandle.FileCreate(AutorunFileName);
            Autorun.AutorunPopulate();
        }

        private static void AutorunPopulate()
        {
            string ExecutableName = Application.ExecutablePath.Substring(3);

            IniFileHandle.addKey("AutoRun", "action", Application.ProductName.ToString(), AutorunFileName);
            IniFileHandle.addKey("AutoRun", "open", ExecutableName, AutorunFileName);
            IniFileHandle.addKey("AutoRun", "icon", ExecutableName + ",0", AutorunFileName);
           
            /*
             * No need to change the label of the drive, as it may has a name olready
             * IniFileHandle.addKey("AutoRun", "label", Application.ProductName.ToString(), AutorunFileName);
             */

            /*
             * The menu definition in the ini file is applicable for the right click menu
             * IniFileHandle.addKey("AutoRun", "shell", "menu", AutorunFileName);
             * IniFileHandle.addKey("AutoRun", "shell\\menu", ExecutableName, AutorunFileName);
             * IniFileHandle.addKey("AutoRun", "shell\\menu\\command", ExecutableName, AutorunFileName);
             */
        }
    }
}